package com.bdqn.dao;

import com.bdqn.pojo.Book;
import com.bdqn.pojo.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import sun.security.timestamp.TSRequest;

import java.util.List;

/**
 * 类名 StudentDao
 * 描述 TODO
 * 日期 2022/2/14 9:50
 * 创建人 by xfq
 * 项目名称 springbootbook
 */
@Mapper
public interface StudentDao {
    //注册
    @Insert("insert into tb_student(sno,password,gender,phone,sname,address,birthday) values (#{sno},#{password},#{gender},#{phone},#{sname},#{address},#{birthday})")
    int addStudent(Student student);
    //登录
    @Select("select * from tb_student where sno = #{sno} and password = #{password}")
    boolean sumStu(@Param("sno")Integer sno,@Param("password")Integer password);
//    boolean sumStu(Student student);
    //书籍页面展示
    @Select("select * from tb_book")
    List<Book> sumBook();
    //动态条件书籍查询
    @Select("<script>select * from tb_book<where><if test='title!=null'>title=#{title}</if><if test ='author!=null'>and author=#{author}</if></where></script> ")
    List<Book> listBook(@Param("title") String title,@Param("author")String author);
    //新增书籍
    @Insert("insert into tb_book (title,author,pshouse,ISBN,psbirthday,inventory,price) values (title=#{title},author=#{author},pshouse=#{pshouse},ISBN=#{ISBN},psbirthday=#{psbirthday},inventory=#{inventory},price=#{price})")
    boolean addBook(Book book);
}
